﻿@model ByWeightModel

@{
    var parentModel = ViewData["Parent"] as ByWeightListModel;
}

<datagrid id="shipping-rates-byweight-grid" class="h-100"
          allow-resize="true"
          allow-row-selection="true"
          allow-column-reordering="true"
          allow-edit="true">
    <datasource read="@Url.Action("ShippingRateByWeightList", "ShippingByWeight")"
                update="@Url.Action("ShippingRateByWeightUpdate", "ShippingByWeight")"
                delete="@Url.Action("ShippingRateByWeightDelete", "ShippingByWeight")" />
    <paging position="Bottom" page-index="1" show-size-chooser="true" />
    <sorting allow-unsort="true" allow-multisort="true">
        <sort by="StoreId" />
        <sort by="CountryId" />
        <sort by="ShippingMethodId" />
        <sort by="From" />
    </sorting>
    <toolbar>
        <toolbar-group>
            <button datagrid-action="DataGridToolAction.ToggleSearchPanel" type="button" class="btn btn-light btn-icon">
                <i class="fa fa-fw fa-filter"></i>
            </button>
        </toolbar-group>
        <toolbar-group>
            <a class="btn btn-primary btn-flat" href="#addrecord-window" data-toggle="modal">
                <i class="fa fa-plus"></i>
                <span>@T("Plugins.Shipping.ByWeight.AddNewRecordTitle")</span>
            </a>
            <button datagrid-action="DataGridToolAction.SaveChanges" type="button" class="btn btn-warning no-anims btn-flat">
                <i class="fa fa-check"></i>
                <span>@T("Admin.Common.SaveChanges")</span>
            </button>
            <button datagrid-action="DataGridToolAction.CancelEdit" type="button" class="btn btn-light btn-flat mr-auto">
                <span>@T("Common.Cancel")</span>
            </button>
        </toolbar-group>
        <zone name="datagrid_toolbar_alpha"></zone>
        <toolbar-group class="omega"></toolbar-group>
        <zone name="datagrid_toolbar_omega"></zone>
        <toolbar-group>
            <button datagrid-action="DataGridToolAction.DeleteSelectedRows" type="button" class="btn btn-danger no-anims btn-flat">
                <i class="far fa-trash-can"></i>
                <span>@T("Admin.Common.Delete.Selected")</span>
            </button>
        </toolbar-group>
    </toolbar>
    <search-panel>
        <partial name="_Grid.ShippingRates.Search" model="parentModel" />
    </search-panel>
    <columns>
        @*INFO: I don't want to hide any columns here so the shop admin doesn't miss any oportunities to configure his rates.*@
        <column for="StoreName" readonly entity-member="StoreId" />
        <column for="CountryName" readonly entity-member="CountryId" />
        <column for="Zip" />
        <column for="ShippingMethodName" entity-member="ShippingMethodId" width="1fr" readonly hideable="false" />
        <column for="From" />
        <column for="To" />
        <column for="UsePercentage" halign="center" />
        <column for="ShippingChargePercentage" />
        <column for="ShippingChargeAmount" />
        <column for="SmallQuantitySurcharge" />
        <column for="SmallQuantityThreshold" />
    </columns>
    <row-commands>
        <a datarow-action="DataRowAction.InlineEdit">@T("Common.Edit")</a>
        <a datarow-action="DataRowAction.Delete">@T("Common.Delete")</a>
    </row-commands>
</datagrid>